//
//  MainLib.m
//  BasicsLib
//
//  Created by 王方伟 on 2017/11/27.
//

#import "MainLib.h"
#import "SHNavigationController.h"
#import "UIBarButtonItem+Extension.h"

#import "SHTabBarView.h"

@implementation MainLib
+ (instancetype)shareInstance{
    static MainLib *shareInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        shareInstance = [[MainLib alloc] init];
    });
    return shareInstance;
}
    
#pragma mark 获取 UITabBarController
+ (SHTabBarViewController *)rootTabBarCcontroller{
    return [SHTabBarViewController shareInstance];
}

#pragma mark 创建一个子控制器
+ (void)addChickViewController:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName isNavController:(BOOL)isNav{
    return [[SHTabBarViewController shareInstance] addChickViewController:childVc title:title imageName:imageName selectImageName:selectImageName isNavController:isNav];
    
}

#pragma mark 创建有导航栏的控制器
+ (void)addChickViewController:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName{
    [self addChickViewController:childVc title:title imageName:imageName selectImageName:selectImageName isNavController:YES];
}
    
#pragma mark 设置全局导航栏背景色
+ (void)setGlobalBackGroundColor:(UIColor *)color{
    UINavigationBar *navBar = [UINavigationBar appearance];
    [navBar setBarTintColor:color];
}
    
#pragma mark 设置全局导航栏标题颜色, 和文字大小
+ (void)setNavBarGlobalTextColor:(UIColor *)globalTextColor andFontSize:(CGFloat)fontSize{
    UINavigationBar *navBar = [UINavigationBar appearance];
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = globalTextColor;
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:fontSize];
    [navBar setTitleTextAttributes:textAttrs];
}

#pragma mark 设置导航返回按钮
+ (void)setNavBarBackImage:(NSString *)image backTitle:(NSString *)title backTitleColor:(UIColor *)color backTitleFontSize:(CGFloat)fontSize{

}

#pragma mark 中间控件的点击代码块
+ (void)setTabbarMiddleBtnClick:(void (^)(BOOL))middleClickBlock{
    SHTabBarView *tabBarView = (SHTabBarView *)[SHTabBarViewController shareInstance].tabBar.subviews.firstObject;
    tabBarView.middleClickBlock = middleClickBlock;
}
@end
